package kr.hkit.androidcomplete01.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class HandlerOrder extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View vw = new MyView(this);
		vw.setOnTouchListener(new View.OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					Log.d("HandlerOrder", "1순위: Listener " + event.getX() + ", " +event.getY());
//					return true;
				}
				return false;
			}
		});
		setContentView(vw);
	}
	
	
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		super.onTouchEvent(event);
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			Log.d("HandlerOrder", "3순위: Activity의 callback method " + event.getX() + ", " +event.getY());
//			return true;
		}
		return false;
	}



	class MyView extends View{

		public MyView(Context context) {
			super(context);
		}

		@Override
		public boolean onTouchEvent(MotionEvent event) {
			super.onTouchEvent(event);
			if(event.getAction() == MotionEvent.ACTION_DOWN){
				Log.d("HandlerOrder", "2순위: View의 callback method " + event.getX() + ", " +event.getY());
				return true;
			}
			return false;
		}
		
	}
}
